      subroutine yaverage(nx,ny,cutoff,dy,data,avg)
      real data(nx,ny),avg(nx),rhoh,cutoff,dy
      integer j1,j2,i,j
      real f1,f2,zero

      zero=0.0
      do i = 1,nx
      avg(i) = 0.
      do j = 1,ny
      j1=j
      j2=j+1
      if (j.eq.ny) then
       j2=j1
      endif
      f1=data(i,j1)
      f2=data(i,j2)
      if (((f1.lt.zero).and.(f2.ge.zero)).or.
     &    ((f1.ge.zero).and.(f2.lt.zero))) then
       avg(i)=(j-0.5)*dy+dy*abs(f1)/(abs(f1)+abs(f2))
      endif
       
c     avg(i) = avg(i) + rhoh(data(i,j),cutoff)/float(ny)
      end do
      end do

      return
      end
